package com.shadow.demo.excel.demo.v3;

import com.alibaba.excel.annotation.ExcelProperty;
import com.shadow.demo.data.excel.entity.DemoExcelEntity;
import com.shadow.demo.excel.demo.v35.ToEntityConverter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = true)
public class Import3VO extends ToEntityConverter<DemoExcelEntity> {

    @Size(min = 2, max = 10)
    @NotBlank(message = "账号不能为空")
    @ExcelProperty(value = "账号", index = 0)
    private String account;

    @NotEmpty(message = "姓名不能为空")
    @ExcelProperty(value = "姓名", index = 1)
    private String name;

//    @Pattern(regexp = "^[1][3,4,5,7,8][0-9]{9}$$", message = "手机号不合法")
//    @NotBlank(message = "手机号不能为空")
//    @ExcelProperty(value = "手机号", index = 2)
//    private String mobile;

    @ExcelProperty(value = "状态", index = 2)
    private String status;

    @ExcelProperty(value = "资产", index = 3)
    private BigDecimal assets;

    @ExcelProperty(value = "创建时间", index = 4)
    private LocalDateTime createTime;

    @Override
    public DemoExcelEntity convert() {
        DemoExcelEntity demoExcelEntity = new DemoExcelEntity();
        BeanUtils.copyProperties(this, demoExcelEntity);
        return demoExcelEntity;
    }
}
